package com.hurl.stock.biz.jcsj;

import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Time;

import org.apache.commons.lang3.StringUtils;

import com.hurl.stock.persistence.JcsjSinaSssjBO;
import com.hurl.stock.persistence.PersistentBO;

public class SinaSssjBuilder extends DSBuilder {
	public PersistentBO processResponseText(String responseBody,DSLocation location){
		SinaSssjLocation loc = (SinaSssjLocation)location;
		
		if(StringUtils.isBlank(responseBody))
			return null;
		
		String content = StringUtils.substringBetween(responseBody, "\"");
		if(StringUtils.isBlank(content)){
			return null;
		}
		
		String[] parts = content.split(",");
		if(parts==null || parts.length==0){
			return null;
		}
		JcsjSinaSssjBO bean = new JcsjSinaSssjBO();
		bean.setGpDm(loc.getGpdm());
		bean.setGpMc(parts[0]);
		bean.setJrkpj(BigDecimal.valueOf(Double.parseDouble(parts[1])));
		bean.setZrspj(BigDecimal.valueOf(Double.parseDouble(parts[2])));
		bean.setDqjg(BigDecimal.valueOf(Double.parseDouble(parts[3])));
		bean.setJrzgj(BigDecimal.valueOf(Double.parseDouble(parts[4])));
		bean.setJrzdj(BigDecimal.valueOf(Double.parseDouble(parts[5])));
		bean.setBuyj(BigDecimal.valueOf(Double.parseDouble(parts[6])));
		bean.setSellj(BigDecimal.valueOf(Double.parseDouble(parts[7])));
		bean.setCjl(Long.valueOf(parts[8]));
		bean.setCjje(BigDecimal.valueOf(Double.parseDouble(parts[9])));
		bean.setBuy1sl(Long.valueOf(parts[10]));
		bean.setBuy1je(BigDecimal.valueOf(Double.parseDouble(parts[11])));
		bean.setBuy2sl(Long.valueOf(parts[12]));
		bean.setBuy2je(BigDecimal.valueOf(Double.parseDouble(parts[13])));
		bean.setBuy3sl(Long.valueOf(parts[14]));
		bean.setBuy3je(BigDecimal.valueOf(Double.parseDouble(parts[15])));
		bean.setBuy4sl(Long.valueOf(parts[16]));
		bean.setBuy4je(BigDecimal.valueOf(Double.parseDouble(parts[17])));
		bean.setBuy5sl(Long.valueOf(parts[18]));
		bean.setBuy5je(BigDecimal.valueOf(Double.parseDouble(parts[19])));
		bean.setSell1sl(Long.valueOf(parts[20]));
		bean.setSell1je(BigDecimal.valueOf(Double.parseDouble(parts[21])));
		bean.setSell2sl(Long.valueOf(parts[22]));
		bean.setSell2je(BigDecimal.valueOf(Double.parseDouble(parts[23])));
		bean.setSell3sl(Long.valueOf(parts[24]));
		bean.setSell3je(BigDecimal.valueOf(Double.parseDouble(parts[25])));
		bean.setSell4sl(Long.valueOf(parts[26]));
		bean.setSell4je(BigDecimal.valueOf(Double.parseDouble(parts[27])));
		bean.setSell5sl(Long.valueOf(parts[28]));
		bean.setSell5je(BigDecimal.valueOf(Double.parseDouble(parts[29])));
		bean.setRq(Date.valueOf(parts[30]));
		bean.setSj(Time.valueOf(parts[31]));
		return bean;
	}
}
